package 赛码.进制转化问题;

import java.util.Scanner;

public class 三进制 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        StringBuffer sbf = new StringBuffer("");
        while(true){
            sbf.insert(0,i%3);
            if(i%3==0&&i/3==1){
                sbf.insert(0,1);
                break;
            }
            if(i<3){
                break;
            }
            i = i/3;
        }
        System.out.println(sbf);
    }
}
